package com.example.demo.mapper;

import com.example.demo.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogInfoMapper {
//    首先点击登录,进入,就会显式所有的博客信息
    @Select("select id,title,content,user_id from blog where delete_flag=0")
    public List<BlogInfo> selectAll();
//    然后是根据博客ID,显示博客信息
    @Select("select id,title,content,user_id from blog where id=#{id} and delete_flag=0")
    public BlogInfo selectById();
    //    插入博客
    @Insert("insert into 'blog' (title,content,user_id) values (#{title},#{content},#{userId})")
    public Integer insertBlog(BlogInfo blogInfo);
//更新博客
//    用户另一种方式写
    public Integer updateBlog(BlogInfo blogInfo);



}
